home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 1.iso / dist / fw_exmh.idb / usr / freeware / lib / exmh-2.5 / sound.tcl.z / sound.tcl
Text File  |  2002-07-08  |  2KB  |  91 lines

  1. # sound.tcl
  2. #
  3. # Audio feedback
  4. #
  5. # Copyright (c) 1993 Xerox Corporation.
  6. # Use and copying of this software and preparation of derivative works based
  7. # upon this software are permitted. Any distribution of this software or
  8. # derivative works must comply with all applicable United States export
  9. # control laws. This software is made available AS IS, and Xerox Corporation
  10. # makes no warranty about the software, its performance or its conformity to
  11. # any specification.
  12.  
  13. proc Sound_Off {} {
  14.     global sound
  15.     set oldValue $sound(enabled)
  16.     set sound(enabled) 0
  17.     return $oldValue
  18. }
  19. proc Sound_On {} {
  20.     global sound
  21.     if {$sound(cmd) != {} || $sound(bell)} {
  22.     set sound(enabled) 1
  23.     }
  24. }
  25. proc Sound_Feedback { delta } {
  26.     global sound exmh
  27.     if {$sound(enabled) && $sound(bell)} {
  28.         if [catch bell] {
  29.             catch blt_bell
  30.         }
  31.         Exmh_Debug bell
  32.         return
  33.     }
  34.     if {!$sound(enabled) || ($sound(cmd) == {})} {
  35.         return
  36.     }
  37.  
  38.     if [string match ~* $sound(newMsg)] {
  39.         set sound(newMsg) [glob -nocomplain $sound(newMsg)]
  40.     }
  41.  
  42.     if ![string match /*  $sound(newMsg)] {
  43.         set sound(newMsg) $exmh(library)/$sound(newMsg)
  44.     }
  45.     set num 0
  46.     while {$delta > 0} {
  47.         incr num
  48.         set delta [expr $delta/4]
  49.     }
  50.     set cmd [concat exec $sound(cmd)]
  51.     if {$sound(multifile)} {
  52.         for {set i 0} {$i < $num} {incr i} {
  53.             lappend cmd $sound(newMsg)
  54.         }
  55.         if [catch {
  56.             eval $cmd &
  57.         } err] {
  58.             Exmh_Debug "Sound_Feedback: $err"
  59.         }
  60.     } else {
  61.         for {set i 0} {$i < $num} {incr i} {
  62.             if [catch {
  63.                 eval $cmd $sound(newMsg)
  64.             } err] {
  65.                 Exmh_Debug "Sound_Feedback: $err"
  66.             }
  67.         }
  68.     }
  69. }
  70.  
  71. proc Sound_Error {  } {
  72.     global sound exmh
  73.     if {!$sound(enabled) || ($sound(cmd) == {})} {
  74.         return
  75.     }
  76.     if [string match ~* $sound(error)] {
  77.         set sound(error) [glob -nocomplain $sound(error)]
  78.     }
  79.     if ![string match /*  $sound(error)] {
  80.         set sound(error) $exmh(library)/$sound(error)
  81.     }
  82.     if [catch {
  83.         eval exec $sound(cmd) $sound(error)
  84.     } err] {
  85.         Exmh_Debug "Sound_Error: $err"
  86.     }
  87. }
  88.  
  89.  
  90.